<!DOCTYPE html> 
<html>
  <head>
    <!--META-->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=0.75">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">

    <!--CSS-->
    <link rel="stylesheet" href="API/css/themes/default/jquery.mobile.min.css" />
    <link rel="stylesheet" href="API/css/datatables/css/jquery.dataTables.css"/>
    <link rel="stylesheet" href="API/css/mycss.css" />
    <link rel="stylesheet" href="css/mycss.css" />

    <!--JS-->
    <script type="text/javascript" src="API/js/jquery.min.js"></script>
    <script type="text/javascript" src="API/js/jquery.mobile.min.js"></script>
    <!--<script type="text/javascript" src="API/js/highcharts.js"></script>-->
    <!--<script type="text/javascript" src="API/js/modules/exporting.js"></script>-->
    <script type="text/javascript" src="API/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="include/config.js"></script>
    <script type="text/javascript" src="API/js/fonctions.js"></script>
    <script type="text/javascript" src="js/fonctions.js"></script>

    <script type="text/javascript">
    checkMaintenance();
    checkAuthentification();
    
    ///////////////////
    //BLOCK VARIABLE GLOBAL
    ///////////////////
    var id_page = 26;

    var g_tags;

    ///////////////////
    //BLOCK FONCTIONS EVENEMENTS
    ///////////////////
    //A la construction de la page
    $(document).on('pageinit',function() {
        try {
            // Init commmun
            init_commun();

            // Init page
        } catch (er) {
            log(0, "ERROR(init_home):" + er.message);
        }
    });

    //Affichage de la page avant onload
    $(document).on('pageshow',function() {
        try {
            show_commun();
        } catch (er) {
            log(0, "ERROR(show):" + er.message);
        }
    });

    //Fin chargement page
    function OnLoad() {
        try {
            chargerTags();
            chargerBanette();
        } catch (er) {
            log(0, "ERROR(OnLoad):" + er.message);
        }
    }

    ///////////////////
    //BLOCK FONCTIONS METIER
    ///////////////////
    /**
     * chargerBanette
     */
    function chargerBanette(){
        try {
            var strhtml = "<IMG SRC=\"API/img/loading.gif\" ALT=\"Chargement\" TITLE=\"Chargement\">";
            $('#div_banette').html(strhtml);
            
            var mostOld = getParameter('mostOld');
            
            var strDateTime = mostOld+" 00:00:01";
            
            var tabInput = buildFiltresTickets({ 
                core_dateTime_creation : strDateTime, 
                core_dateTime_creation_option : "AP", 
                core_respon : auth, 
                vue_version : "true", 
                vue_categorie : "true",
                core_statut : "1,2,3,4,7,8", 
                core_statut_option : "list"
            });
            callBD("phpsql/mysql_getTickets.php", "POST", "json", tabInput, "vueBanette");
            
            var strParams = buildParams(tabInput);
            strhtml = "<a href=\"javascript:window.location = ('./phpsql/mysql_getTickets.php?ODASortie=csv&ODAFilename=banette"+strParams+"');\" data-role=\"button\" data-inline=\"true\" data-mini=\"true\" title=\"CSV Export\">CSV Export</a>";
            $('#div_banette_csv').html(strhtml).trigger('create');         
        } catch (er) {
            log(0, "ERROR(chargerBanette):" + er.message);
        }
    }

    ///////////////////
    //BLOCK FONCTIONS AFFICHAGE
    ///////////////////
    /**
     * vueBanette
     * 
     * @param {array} p_retour
     */
    function vueBanette(p_retour){
        try {
            var objDataTable = objDataTableFromJsonArray(p_retour["data"]["resultat"]["data"]);
            
            $('#div_banette').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="tab_banette"></table>' );
            var oTable = $('#tab_banette').dataTable( {
                "oLanguage": {"sUrl": "css/datatables/dataTables_I8N/lang_FR.json"},
                "iDisplayLength": 50,
                "sPaginationType": "full_numbers",
                "aaData": objDataTable.data,
                "aaSorting": [[2,'desc']],
                "sScrollX": '100%',
                "sScrollXInner": "2780px",
                "bScrollCollapse": true,
                "bAutoWidth": false,
                "aoColumns": [
                    { sTitle : "Label", sClass : "left", sWidth : "100px" },
                    { sTitle : "Nature", sClass : "left", sWidth: "50px" },
                    { sTitle : "Date de création", sClass : "center", sWidth : "140px" },
                    { sTitle : "Version", sClass : "center", sWidth: "50px" },
                    { sTitle : "Statut", sClass : "left", sWidth: "90px" },
                    { sTitle : "Priorité", sClass : "left", sWidth: "50px" },
                    { sTitle : "Criticité", sClass : "left", sWidth: "50px" },
                    { sTitle : "Catégorie", sClass: "left", sWidth: "50px" },
                    { sTitle : "Description", sClass: "left", sWidth: "2200px"}
                ],
                "aoColumnDefs": [
                    {//Label
                        "mRender": function ( data, type, row ) {
                            return '<a target="_top" href="page_ticket.html?id_page='+id_page+'&id='+row[objDataTable.entete["idElem"]]+'&id_toc='+row[objDataTable.entete["label"]]+'&mili='+getMilise()+'">'+row[objDataTable.entete["label"]]+'</a>';
                        },
                        "aTargets": [ 0 ]
                    },
                    {//Nature
                        "mRender": function ( data, type, row ) {
                            return tradId(row[objDataTable.entete["nature"]],"tag");
                        },
                        "aTargets": [ 1 ]
                    },
                    {//Date création
                        "mRender": function ( data, type, row ) {
                            if ( type == 'display' ) {
                                return getShortStrDateTimeFrFromUs(row[objDataTable.entete["dateTime_creation"]]);
                            }
                            return row[objDataTable.entete["dateTime_creation"]];
                        },
                        "aTargets": [ 2 ]
                    },
                    {//Version
                        "mRender": function ( data, type, row ) {
                            return row[objDataTable.entete["version"]];
                        },
                        "aTargets": [ 3 ]
                    },
                    {//Statut
                        "mRender": function ( data, type, row ) {
                            return tradId(row[objDataTable.entete["statut"]],"tag");
                        },
                        "aTargets": [ 4 ]
                    },
                    {//Priorité
                        "mRender": function ( data, type, row ) {
                            if ( type == 'display' ) {
                                return tradId(row[objDataTable.entete["priorite"]],"tag");
                            }
                            return row[objDataTable.entete["priorite"]];
                        },
                        "aTargets": [ 5 ]
                    },
                    {//Criticité
                        "mRender": function ( data, type, row ) {
                            return tradId(row[objDataTable.entete["criticite"]],"tag");
                        },
                        "aTargets": [ 6 ]
                    },
                    {//Categorie
                        "mRender": function ( data, type, row ) {
                            return tradId(row[objDataTable.entete["categorie"]],"tag");
                        },
                        "aTargets": [ 7 ]
                    },
                    {//Description
                        "mRender": function ( data, type, row ) {
                            return row[objDataTable.entete["description"]];
                        },
                        "aTargets": [ 8 ]
                    }
                ]
            });
        } catch (er) {
            log(0, "ERROR(vueBanette):" + er.message);
        }
    }
</script>

</head>
<body onload="OnLoad();">

    <!-- page -->
    <div data-role="page" data-title="Titre">

        <!-- /panel -->
        <div data-role="panel" id="mypanel" data-display="overlay" data-position="left">

        </div>
        <!-- /panel -->

        <!-- header -->
        <div data-role="header" data-position="fixed">
            <a href="#mypanel" data-role="button" data-icon="home" data-iconpos="notext">home</a>
            <h1 id="id_titre">titre</h1>
            <a href="javascript:window.location = ('./page_contact.html?mili='+getMilise());" data-role="button" data-icon="info" data-iconpos="notext">Contact</a>
        </div>
        <!-- /header -->
        
        <!-- navbar -->
        <!-- /navbar -->

        <!-- content -->
        <div data-role="content" id="main_content">
            <div data-role="collapsible" data-collapsed="false" data-mini="true">
                <h4>Votre banette</h4>
                <div id="div_banette"></div>
                <br>
                <label id="div_banette_csv"></label>
            </div>      
        </div>
        <!-- /content -->

        <!-- footer -->
        <div data-role="footer" data-position="fixed">
            <a data-role="button" data-icon="search" data-iconpos="notext" class="ui-btn-left" href="javascript:window.location = ('./page_faq.html?mili='+getMilise());">FAQ</a>
            <h1 id="id_affichageUser">User</h1>
            <a data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right" href="javascript:window.location = ('./page_sortie.html?mili='+getMilise());">Logout</a>
        </div>
        <!-- /footer -->

    </div>
    <!-- /page -->
</body>
</html>